import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;


import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ExcelImport {
	
//	private List<Node> getRowCountOrdered(List<Sheet> sheets){
//		
//		List<Node> rowCount = new ArrayList<Node>();
//		for (int i = 0; i < sheets.size(); i++) {
//			
//			rowCount.get(i).setRowsNumber(sheets.get(i).getRows());
//		}
//		return rowCount;
//	
//	}
	
	private List<List> probandenListen = new ArrayList<List>();
	

	void importSheet(File file) throws BiffException, IOException{
		
		
		Workbook workbook = Workbook.getWorkbook(file);
		Sheet[] sheets = workbook.getSheets();
		List<Sheet> sheetsTmp = Arrays.asList(sheets);
		
//		List<Node> rowCount = getRowCountOrdered(sheetsTmp);
		
		Iterator iterator = sheetsTmp.iterator();
	
		
	while (iterator.hasNext()) {
		Sheet sheet= (Sheet) iterator.next();
		
		List<Proband> probandListe = new ArrayList<Proband>();

		
		for (int i = 1; i < sheet.getRows(); i++) {
		
			Proband proband = new Proband("Arschgesicht",getCellCont(sheet,"v_156",i),sheet.getName());
			System.out.println(proband.getName() + " "+proband.getId()+ " "+proband.getOrigin()+" wurde gespeichert");
			
			proband.addLand("Bangladesch a", getCellCont(sheet,"Bangladesch a",i));
			proband.addLand("Mexiko a", getCellCont(sheet,"Mexiko a",i));
			proband.addLand("Japan a", getCellCont(sheet,"Japan a",i));
			proband.addLand("Israel a", getCellCont(sheet,"Israel a",i));
			proband.addLand("Deutsch a", getCellCont(sheet,"Deutsch a",i));
			proband.addLand("Frank a", getCellCont(sheet,"Frank a",i));
			proband.addLand("USA a", getCellCont(sheet,"USA a",i));
			proband.addLand("Spanien a", getCellCont(sheet,"Spanien a",i));
			proband.addLand("Russ a", getCellCont(sheet,"Russ a",i));
			proband.addLand("Indien a", getCellCont(sheet,"Indien a",i));
			
			
			probandListe.add(proband);
			
		}
	
		probandenListen.add(probandListe);
		
		
	}
	

		
	
	}
	


	String getCellCont(Sheet sheet, String colName, int row){
		
		int namePointer = sheet.findCell(colName).getColumn();
		return sheet.getCell(namePointer,row).getContents();
		
	}



	List<List> getProbandenListen() {
		return probandenListen;
	}


}
